Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add getChunk method to FrameSet and substitute its result into commands #367

Merged

Conversation

donalm
Copy link
Contributor

@donalm donalm commented Jul 3, 2019

Submitted as a WIP because:

  • I'm not very confident in Java
  • You guys probably have your own ideas about how to approach this

But - it works well enough for me that I can proceed with testing.

This update allows me to submit a command like this:

/bin/true -f #FRAMESPEC#

And the rqd daemon is assigned something like this (depending on framerange/chunk size):

/bin/true -f 12-24x2

The logic is ported directly from FileSeq.

@bcipriano
Copy link
Collaborator

Hi @donalm, sorry for the radio silence here. It's a bit of a complex PR and we just haven't yet been able to block out time for it yet! But it's on our radar.

@donalm
Copy link
Contributor Author

donalm commented Jul 10, 2019

No worries - thanks @bcipriano

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry again for the delay here! This is looking good to me. I've left a bunch of comments but they're mostly around code style -- the main logic here looks good to me.

Thanks for sending this!

* @param zFill The required width of each left-padded frame ID, e.g. 4 if ID '1' should become '0001'
* @return A representation of a frameset, e.g. '1-10,12-100x2'
*/
private String framesToFrameRanges(ImmutableList<Integer> frames, int zFill) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like there's a way to use zFill at the moment, is there? Since these are all private methods, and the public methods don't have a corresponding argument. Should we just drop it?

If you think it's worth keeping it around, let's add tests that utilize it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all the zFill and pad method stuff that's not really being used.

sb.append(resultBuilder.get(j)).append(",");
}
sb.append(resultBuilder.get(l));
return sb.toString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a slight rewrite of this block which uses Java 8 streams and a StringJoiner to handle adding the delimiters.

StringJoiner sj = new StringJoiner(",");
resultBuilder.forEach(sj::add);
return sj.toString();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks I was was looking for something like this.

return pad(frames.get(0), zFill);
}

ArrayList<String> resultBuilder = new ArrayList<String>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can drop the second String, it's redundant.

ArrayList<String> resultBuilder = new ArrayList<>();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I don't need this variable now because I'm just using StringJoiner directly

@donalm
Copy link
Contributor Author

donalm commented Aug 24, 2019

Thanks for the review Brian. I think I addressed everything you raised but please bounce it back to me if there's still some stuff to improve.

Copy link
Collaborator

@bcipriano bcipriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@donalm Were you able to resolve any issues with the CLA? I noticed on #434 that it was throwing a warning.

@gregdenton Would you mind taking a quick look at this PR as well?

@donalm
Copy link
Contributor Author

donalm commented Sep 10, 2019

Aye the CLA got resolved and the repo seemed to recognise that without any intervention which was nice. I think this just needs the nod from @gregdenton now.

Thanks @bcipriano

Copy link
Collaborator

@gregdenton gregdenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @donalm!

@bcipriano bcipriano merged commit 152ef14 into AcademySoftwareFoundation:master Sep 12, 2019
@donalm donalm deleted the framespec_token_104 branch September 12, 2019 11:26
@donalm
Copy link
Contributor Author

donalm commented Sep 12, 2019

That's great! Thanks everyone.

DiegoTavares pushed a commit that referenced this pull request Aug 29, 2024
**Link the Issue(s) this Pull Request is related to.**
#1129 

**Summarize your change.**
Fix the frame end resolution of a frame chunk used to fill the place
holder `#FRAME_END#`.
The current behavior incorrectly returns the index of the last frame in
the frame list instead of its value.

Leverage `FrameSet.get_chunk` method that is already doing all the
legwork to get the last frame.


**Related topics**
- #1320
- #367

---------

Signed-off-by: Anton Brand <[email protected]>
Co-authored-by: Kern Attila GERMAIN <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants